package tech.aistar.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import tech.aistar.entity.UserInfo;
import tech.aistar.entity.UserRelation;

import java.util.List;
import java.util.Map;
import java.util.Set;

@RunWith(SpringRunner.class)
@SpringBootTest
public class RelationServiceTest {
    @Autowired
    private IUserRelationService userRelationService;
    @Autowired
    private IUserInfoService userInfoService;


    @Test
    public void test04(){
        List<UserInfo> list = userRelationService.findFocuInfo(1);
//        System.out.println("+++++++++++++++++++");
         System.out.println("chaxun::::"+list.size());
//        System.out.println("++++++++++++++++++++++++++++++++++++++++");
//        PageInfo<UserInfo> infolist = pagefService.findFoucPage(1,1,7);
//        PageInfo<UserRelation> infolist = userRelationService.findFoucInfo(1,1,4);

        Map<PageInfo<UserRelation>,List<UserInfo>> focumap = userRelationService.findFoucNum(1,1,3);
        Set<PageInfo<UserRelation>> set =focumap.keySet();
        for(PageInfo<UserRelation> focuPage:set){
            System.out.println(focuPage);
            List<UserInfo> focuinfo = focumap.get(focuPage);
            System.out.println("当前页:"+focuPage.getPageNum());
            System.out.println("每页显示的条数:"+focuPage.getPageSize());
            System.out.println("总页数:"+focuPage.getPages());
            System.out.println("+++++++这是一个华丽丽的分割线+++++++++");
            focuinfo.size();
            focuinfo.forEach(System.out::println);
        }
//        // 当前页
    }
    @Test
    public void addtest(){
        UserInfo u01 = userInfoService.findById(1);
        System.out.println("关注数: "+u01.getFoucNum()+"粉丝数:  "+u01.getFansNum());
        System.out.println("______________________________________________________");
        UserInfo u02 = userInfoService.findById(11);
        System.out.println("关注数: "+u02.getFoucNum()+"粉丝数:  "+u02.getFansNum());
        UserRelation u = new UserRelation(null,11,null,1,0);
        userRelationService.addShip(u);
        System.out.println("******************************************************");
        UserInfo u03 = userInfoService.findById(1);
        System.out.println("关注数: "+u03.getFoucNum()+"粉丝数:  "+u03.getFansNum());
        System.out.println("______________________________________________________");
        UserInfo u04 = userInfoService.findById(11);
        System.out.println("关注数: "+u04.getFoucNum()+"粉丝数:  "+u04.getFansNum());
    }

    @Test
    public void deltest(){
        UserInfo u01 = userInfoService.findById(1);
        System.out.println("关注数: "+u01.getFoucNum()+"粉丝数:  "+u01.getFansNum());
        System.out.println("______________________________________________________");
        UserInfo u02 = userInfoService.findById(11);
        System.out.println("关注数: "+u02.getFoucNum()+"粉丝数:  "+u02.getFansNum());
        //UserRelation u = new UserRelation(null,11,null,1,0);
        userRelationService.delFouc(11,1);
        System.out.println("******************************************************");
        UserInfo u03 = userInfoService.findById(1);
        System.out.println("关注数: "+u03.getFoucNum()+"粉丝数:  "+u03.getFansNum());
        System.out.println("______________________________________________________");
        UserInfo u04 = userInfoService.findById(11);
        System.out.println("关注数: "+u04.getFoucNum()+"粉丝数:  "+u04.getFansNum());
    }

    @Test
    public void test(){
        System.out.println(userRelationService.bothShip(1,2));

    }
}
